import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'

export function useLazyDate(apiFn: () => void){
  const target = ref(null)
  const { stop } =  useIntersectionObserver(target,([{ isIntersecting }]) => {
    if(isIntersecting){
      stop()
      apiFn()
    }
  },{
    threshold: 0
  })
  
  return target
}